package com.xiaoyaoji.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author liyacai
 * @description
 * @date 2020/6/11
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {


    /**
     * 配置Swagger的Docket的Bean实例
     * @return Docket
     */
    @Bean
    public Docket docket(ApiInfo apiInfo) {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.xiaoyaoji.admin.controller"))
                .build();
    }

    /**
     * 配置Swagger信息
     * @return ApiInfo
     */
    @Bean
    public ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("小幺鸡扩展 API 文档").version("v1.0").build();
    }
}
